package valuecomusa.fijibus.eticket;

import java.nio.charset.Charset;

/**
 * Created with IntelliJ IDEA.
 * User: fireman
 * Timestamp: 5/16/13
 * Time: 10:16 AM
 * To change this template use File | Settings | File Templates.
 */
public class Encryptor
{
    public static String MD5(String value)
    {
        try
        {
            java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
            byte[] array;
            array = md.digest(value.getBytes(Charset.forName("UTF8")));
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < array.length; ++i)
            {
                sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1, 3));
            }
            return sb.toString().toUpperCase();
        }
        catch (java.security.NoSuchAlgorithmException e)
        {
        }
        return null;
    }
}
